package com.hockeo.shared.domain.persistent;

import java.util.Date;

import com.hockeo.shared.domain.AbstractDomain;
import com.hockeo.tinygds.annotation.TEntity;
import com.hockeo.tinygds.annotation.TId;
import com.hockeo.tinygds.annotation.TName;
import com.hockeo.tinygds.annotation.TUnindexed;

/**
 * Represents a binary image.
 *
 * @version $Id$
 * @author jjanke
 */
@TEntity
public class Image extends AbstractDomain<Image, String>
{
  @TId
  private String d_strId;

  @TName( "mime_type" )
  @TUnindexed
  private String d_strMimeType;

  @TName( "desc" )
  @TUnindexed
  private String d_strDesc;

  @TName( "create_date" )
  private Date   d_dateCreated;

  @TName( "data" )
  private byte[] d_abData;

  /** Argument-less constructor for TinyGDS and GWT/RPC. */
  private Image()
  {}

  public Image( String strId, String strMimeType, byte[] abData )
  {
    d_strId = strId;
    d_strMimeType = strMimeType;
    d_abData = abData;
    d_dateCreated = new Date();
  }

  public String getMimeType()
  {
    return d_strMimeType;
  }

  public String getDesc()
  {
    return d_strDesc;
  }

  public void setDesc( String strDesc )
  {
    d_strDesc = strDesc;
  }

  public byte[] getData()
  {
    return d_abData;
  }

  public Date getDateCreated()
  {
    return d_dateCreated;
  }

  @Override
  public String getEntityName()
  {
    return "Image";
  }

  @Override
  public String getId()
  {
    return d_strId;
  }

}
